package com.docMan.dao;

import java.io.Serializable;
import java.util.List;
import java.util.Map;

import org.hibernate.Query;

import com.docMan.bean.Page;
/**
 * 
 * @author Administrator
 * 所有带key的方法是指缓存的key
 * @param <T>
 */
public interface BaseDao<T> {
	public abstract void delete(int id);
	public abstract void delete(T entity);
	public abstract T getById(Serializable id);
	public abstract List<T> findAll(String key);
	abstract List<T> findAll();
	public abstract List<T> findByIds(String[] ids);
	public abstract int save(T entity);
	public abstract void update(T entity);
	abstract List<List> find(String hqlString);
	abstract List<List> find(Query query);
	public abstract List<T> find(String key,String hql);
	public abstract List<T> findNoCache(String hql);
	public abstract List<T> find(String key,String hql,Object... values);
	abstract List<Object> findSqlNoCache(String sql,Object...objects);
	abstract List<Object> findSqlNoCache(String sql);
	abstract List<T> findNoCache(String hql,Object...objects);
	abstract List<T> find(String hql,List<String> classes,List<String> params);
	abstract List<T> find(String hql,List<String> params);
	public abstract List<T> query(String hql);
	public abstract List<T> query(String hql,int page,int pageSize);
	public abstract List<T> query(String hql,Object...objects);
	public abstract void saveOrUpdate(T entity);
	public abstract void saveOrUpdateAll(List<T> list);
	public abstract int update(String hql,Object...objects);
	public abstract int update(String hql);
	public abstract int excudeSqlUpdate(String sql,Object...objects);
	public abstract int excudeSql(String sql);
	abstract int queryBySql(String sql);
	abstract long count(String hql,Object...objects);
	public abstract List<T> pageQuery(String hql,int page,int pageSize,Object... objects);
	public abstract Page<T> page(String hql,Page<T> page);
	abstract Page<T> restPage(String key,String hql,Page<T> page);
	abstract Page<T> restPageNoCache(String hql,Page<T> page);
	public abstract List<T> createCriteria(int page,int pageSize,Map<String, Object> map);
	public abstract List<T> createCriteria(Map<String, Object> map);
	
	abstract Query getQuery(String hql);
	/**
	 * 因为 分页查询时的条件比较复杂，有时间范围的比较，参数条件变动比较大，所以将query 的创建和参数设置
	 * 提到上层 service中去，减少dao接口的差异性
	 * @param page
	 * @param query
	 * @return
	 */
	abstract Page<T> newPage(Page<T> page,Query query);
}
